package com.tools;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;

import java.util.Date;

public class Hutools {
    public static void main(String[] args) {

        DateTime date = DateUtil.date();
        System.out.println(date);

        //日期转换
        String dateStr = "2020-09-29";
        System.out.println(DateUtil.parse(dateStr));

        //时间差
        String dateStr1 = "2020-09-29 22:33:23";
        Date date1 = DateUtil.parse(dateStr1);

        String dateStr2 = "2020-10-01 23:34:27";
        Date date2 = DateUtil.parse(dateStr2);
        System.out.println(DateUtil.between(date1, date2, DateUnit.HOUR));
    }
}
